//
//  JYTSchoolHeader.m
//  JYT_IOS
//
//  Created by nxa-tankeke on 17/1/6.
//  Copyright © 2017年 nxa-yuanguoxiang. All rights reserved.
//

#import "JYTSchoolHeader.h"
#import <UIImageView+WebCache.h>
#import "School.h"

@interface JYTSchoolHeader()
@property (weak, nonatomic) IBOutlet UIImageView *schoolHearImageView;

@property (weak, nonatomic) IBOutlet UILabel *schoolNameLabel;

@property (weak, nonatomic) IBOutlet UILabel *studentCountLabel;

@property (weak, nonatomic) IBOutlet UILabel *priceLabel;

@property (weak, nonatomic) IBOutlet UIImageView *oneLevel;
@property (weak, nonatomic) IBOutlet UIImageView *twoLevel;
@property (weak, nonatomic) IBOutlet UIImageView *threeLevel;
@property (weak, nonatomic) IBOutlet UIImageView *fourLevel;
@property (weak, nonatomic) IBOutlet UIImageView *fiveLevel;
@end


@implementation JYTSchoolHeader

+ (instancetype)header
{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
}

-(void)setSchool:(School *)school
{
    _school = school;
    
    NSString *imgURL = school.logoUrl;
    if (imgURL) {
        [self.schoolHearImageView sd_setImageWithURL:[NSURL URLWithString:imgURL] placeholderImage:[UIImage imageNamed:@"02驾校查询_22"]];
    } else {
        [self.schoolHearImageView setImage:[UIImage imageNamed:@"02驾校查询_22"]];
    }
     [self.studentCountLabel setText:[NSString stringWithFormat:@"已有%@学员报名",school.studentNum]];
    
    NSString *price =  school.price;
    NSString *newPrice = [NSString stringWithFormat:@"¥%@起",price];
    [self.priceLabel setText:newPrice];
    
    
    NSString *starLevel = school.starLevel;
    if ([starLevel isEqualToString:@"1"]) {
        [self.oneLevel setHidden:YES];
        
    } else if([starLevel isEqualToString:@"2"]) {
        [self.oneLevel setHidden:YES];
        [self.twoLevel setHidden:YES];
        
    } else if([starLevel isEqualToString:@"3"]) {
        [self.oneLevel setHidden:YES];
        [self.twoLevel setHidden:YES];
        [self.threeLevel setHidden:YES];
        
    } else if([starLevel isEqualToString:@"4"]) {
        [self.oneLevel setHidden:YES];
        [self.twoLevel setHidden:YES];
        [self.threeLevel setHidden:YES];
        [self.fourLevel setHidden:YES];
        
    } else if([starLevel isEqualToString:@"5"]) {
        [self.oneLevel setHidden:YES];
        [self.twoLevel setHidden:YES];
        [self.threeLevel setHidden:YES];
        [self.fourLevel setHidden:YES];
        [self.fiveLevel setHidden:YES];
    }


    [self.schoolNameLabel setText:school.drivingSchoolName];
}

- (instancetype)init
{
    self = [super init];
    
    if (self) {
        
        
    }
    
    return self;
}

@end
